package com.study.graph.util;

import sun.misc.Signal;
import sun.misc.SignalHandler;

//@SuppressWarnings("restriction")
public class SignalCatch  implements SignalHandler{
	private static boolean needEnd = false;
	
	public static boolean getEndStat(){
		return needEnd;
	}
	
	@Override
	public void handle(Signal sigName) {
		signalCallback(sigName);
	}

	private void signalCallback(Signal sigName) {
		//System.out.println("CHK catch signal " + sigName.getName());
		needEnd = true;		
	}
	
	public static void main(String[] args)  {
		SignalCatch testSignal = new SignalCatch();
		Signal.handle(new Signal("TERM"), testSignal);
		
		while(true){
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {			
				e.printStackTrace();
			}
		}
	}

}

